function fn(a,b) {
    console.log('this',this)
    console.log('a+b',a+b);
    return a + b
}

const p = {name: '章三'}

// fn.apply(p,[1,2])

Function.prototype.myApply = function (ctx,args) {
  ctx = (ctx === null || ctx === undefined) ? globalThis : ctx;
  const key = Symbol();
  Object.defineProperty(ctx,key,{
    enumerable: false,
    value: this
  });
  ctx[key] = this;
  const result =  ctx[key](...args);
  delete ctx[key];
  return result; 
}

fn.myApply(p,[1,2]);
